package com.liyu.service;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.liyu.domain.Book;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;


@SpringBootTest
public class BookServiceTestCase {

    @Autowired
    private BookService bookService;

    @Test
    public void testGetById() {
        Book book = bookService.getById(1);
        System.out.println(book);
    }

    @Test
    public void testSave(){
        Book book = new Book();
        book.setType("测试数据100");
        book.setName("测试数据2");
        book.setDescription("测试数据3");
        bookService.save(book);

    }

    @Test
    public void testUpdate(){
        Book book = new Book();
        book.setId(1);
        book.setType("修改测试数据1");
        book.setName("测试数据2");
        book.setDescription("测试数据3");
        bookService.update(book);

    }

    @Test
    void testDelete(){
        bookService.delete(22);
    }

    @Test
    void testGetAll(){
        bookService.getAll();
    }


    @Test
    void testGetPage() {
        IPage<Book> page = bookService.getPage(2, 5);
        System.out.println(page.getCurrent());
        System.out.println(page.getSize());
        System.out.println(page.getTotal());
        System.out.println(page.getPages());
        System.out.println(page.getRecords());
    }













}
